package com.adwin.addcoin.ui.viewholder

import android.text.TextUtils
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView.ViewHolder
import com.adwin.addcoin.R
import com.adwin.addcoin.databinding.HomeTaskItemBinding
import com.adwin.addcoin.repository.bean.HomeTaskBean
import com.bumptech.glide.Glide

class TaskItemHolder(val binding:HomeTaskItemBinding): ViewHolder(binding.root) {

    fun upDateTask(bean:HomeTaskBean){

        Glide.with(itemView).load(bean.taskIcon).error(R.mipmap.addcoins_acquiesce_icon).placeholder(R.mipmap.addcoins_acquiesce_icon).into(binding.ivTaskIcon)
        binding.tvTaskCoins.text = "${bean.coins}"
        binding.tvTaskName.text = "${bean.appName?:""}"
        binding.tvTaskDescription.text = "${bean.description?: ""}"
        if (!TextUtils.isEmpty(bean.label)){
            when (bean.label) {
                "hot", "HOT" -> {
                    binding.tvHotTitle.text = "hot"
                    binding.tvHotTitle.visibility = View.VISIBLE
                }
                "new", "NEW" -> {
                    binding.tvHotTitle.text = "new"
                    binding.tvHotTitle.visibility = View.VISIBLE
                }
                else -> {
                    binding.tvHotTitle.visibility = View.GONE
                }
            }
        }
    }
}